
# To set the working dir 

setwd('/home/clint/ldappmcpp/ldappm_cpp/src') 
# setwd('/home/clint/ldappm/src')

# Loads the necessary R pkgs 

library(MCMCpack);
library(plotrix);

# Includes the source files  

source('process_data.R');
source('utils.R');
source('lda_ppm.R');
source('lda_ppm_learnK.R');
source('topic_search.R');
source('read.vocab.R');
source('top.topic.documents.R');
source('top.topic.words.R');


train.gibbs.beta <- read.table(file = "../LDA_beta_samples_mean.dat");
train.gibbs.theta <- read.table(file = "../LDA_theta_samples_mean.dat");

train.gibbs.pin <- read.table(file = "../LDA_prob_in.dat");
train.gibbs.pex <- read.table(file = "../LDA_prob_ex.dat");

train.gibbs.pin <- train.gibbs.pin / colSums(train.gibbs.pin);
train.gibbs.pex <- train.gibbs.pex / colSums(train.gibbs.pex);


r <- log ((1 - train.gibbs.pin)/(1 - train.gibbs.pex)); 
r[is.na(r)] <- 0.0;
kl.word <- train.gibbs.pin * log(train.gibbs.pin / train.gibbs.pex) + (1 - train.gibbs.pin) * r; 

news.vocab <- read.vocab("../matMarch.domains");
colnames(kl.word) <- news.vocab;
top.topic.words(kl.word, num.words=10, by.score=FALSE); # displays top topics

colnames(train.gibbs.beta) <- news.vocab;
top.topic.words(train.gibbs.beta, num.words=10, by.score=TRUE); # displays top topics


